package com.mybatisplus.mp.pojo;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {
    //        @TableId(type= IdType.AUTO) 数据库自增，数据库主键需要设置自增
    //默认雪花算法生成主键
//    @TableId
    // 分组只会校验组里的
    @NotNull(message = "id校验"/*,groups = {SaveGroup.class}*/)
//    @NotEmpty
//    @NotBlank
//    @Length(max = 3)
    @ApiModelProperty(value = "")
    private Long id;
    //@NotNull(message = "dsaf")
    @NotBlank(message = "dsafasf", groups = {SaveGroup.class})
    @Length(max = 1, groups = {SaveGroup.class})
    private String name;
    //    @Length(max = 1, groups = {SaveGroup.class})
//    @Size(max = 1, groups = {SaveGroup.class})
//    @Size
//    @Max(10) //校验大小不是长度
//    @Min(1)

    private Integer age;
    private String email;
    @Version
    private Integer version;//乐观锁
    @TableLogic
//    @TableLogic(value="1",delval = "0")
    private Integer deleted;

    @TableField(value = "createTime")
    private Date cTime;

    @TableField(value = "updateTime")
    private Date uTime;

    @TableField(exist = false)
    private Date testDate;

    @TableField(exist = false)//数据库不存在该字段
    private Integer[] integers;

    // 分组配置
    public interface SaveGroup {

    }

}
